import { Component } from 'react'; 

export default class ChildCycle2 extends Component {
	// 总数据
	state = {
		// 新增-弹窗开头
		name2: ''
	}
	
	// 挂载阶段-从props中获取state
	static getDerivedStateFromProps (nextProps, prevState) {
		console.log('getDerivedStateFromProps 2', 2);
		return null;
	}
	// 渲染函数
    render() {
    	console.log('render 2', 2)
    	return (
			<div>
				ChildCycle2:{this.props.name}
			</div>
		);
    }
    // 挂载阶段-挂载完成
	componentDidMount () {
		console.log('componentDidMount 2', 4);
	}

	// 更新阶段-是否执行更新
	shouldComponentUpdate (nextProps, nextState) {
		console.log('shouldComponentUpdate 2', 11)
		return true;//true,重调render;false,不重调render
	}
	// 更新阶段-在render之前调用，state已更新
	getSnapshotBeforeUpdate (prevProps, prevState) {
		console.log('getSnapshotBeforeUpdate 2', 12);
		return 1024;
		//return null;
	}
	// 更新阶段-第三个参数从 getSnapshotBeforeUpdate 接收而来
	componentDidUpdate (perProps, perState, params) {
		console.log('componentDidUpdate 2', 13, params);//params:1024
	}
	
};
